package com.carsystem.controller;


import com.carsystem.request.OrderRequestVo;
import com.carsystem.response.OrderResponseVo;
import com.carsystem.service.IOrderService;
import com.carsystem.utils.*;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ykl
 * @since 2021-12-04
 */
@RestController
@RequestMapping("/order")
public class OrderController extends BaseController{

    @Reference
    private IOrderService orderService;

    /**
     * 订单状态审核
     * @param id
     * @return
     */
    @RequestMapping("/updateStatus/{id}")
    public Result updateStatus(@PathVariable Integer id){
        return orderService.updateStatus(id);
    }

    /**
     * 订单分页查询
     * @param orderRequestVo
     * @return
     */
    @RequestMapping("/selectPage")
    public ResultEntity<OrderResponseVo> selectOrderByPage(@RequestBody OrderRequestVo orderRequestVo){
        Map<String, Object> returnMap = new HashMap<>();
        PageHandler pageHandler = orderService.selectOrderByPage(orderRequestVo);
        returnMap.put("page",pageHandler);
        return getSuccessEntity(returnMap);
    }
    /**
     * 订单修改
     */
    @RequestMapping("/updateOrder")
    public Result updateOrder(@RequestBody OrderResponseVo orderResponseVo){
        return orderService.updateOrderResponse(orderResponseVo);
    }


}

